/**
 * @file bsp_iic.h
 * @author liufeng (liufeng@injoinic.com)
 * @brief software iic.
 * @version 0.1
 * @date 2024-10-31
 *
 * @copyright Copyright (c) 2024  injoinic
 *
 */

#ifndef __BSP_IIC_H__
#define __BSP_IIC_H__

#include "main.h"
#include "stdint.h"

/* User config -------------------------------------------------------------- */

#define SCL_High    HAL_GPIO_WritePin(SW_SCL_GPIO_Port, SW_SCL_Pin, GPIO_PIN_SET)
#define SCL_Low     HAL_GPIO_WritePin(SW_SCL_GPIO_Port, SW_SCL_Pin, GPIO_PIN_RESET)

#define SDA_High    HAL_GPIO_WritePin(SW_SDA_GPIO_Port, SW_SDA_Pin, GPIO_PIN_SET)
#define SDA_Low     HAL_GPIO_WritePin(SW_SDA_GPIO_Port, SW_SDA_Pin, GPIO_PIN_RESET)
#define SDA_Readpin HAL_GPIO_ReadPin(SW_SDA_GPIO_Port, SW_SDA_Pin)

/* Private functions ---------------------------------------------------------*/

void iic_init(void);
void iic_deinit(void);

/* Exported functions ------------------------------------------------------- */

uint8_t iic_write_bytes(uint8_t slave_addr, uint8_t* buff, uint8_t buff_len);
uint8_t iic_read_bytes(uint8_t slave_addr, uint8_t* buff, uint8_t buff_len);
uint8_t iic_write_memory(uint8_t slave_addr, uint8_t reg_addr, uint8_t* buff, uint8_t buff_len);
uint8_t iic_read_memory(uint8_t slave_addr, uint8_t reg_addr, uint8_t* buff, uint8_t buff_len);

#endif /* __BSP_IIC_H__ */
